#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :关联分析.py
# @Time      :2024/11/27 
# @Author    :CL
# @email     :1037654919@qq.com
# 关联分析，必须以周一作为起始日
from scrapy_juliangsuanshu import *

def get_relation_words_run():
    keyword = '长安'
    app_name = 'aweme'
    enddate = '20220116'
    date ='20220110'
    datastr = get_relation_words(keyword=keyword, start_date=date, end_date=enddate, app_name=app_name)
    datas = decrtptlx(datastr)
    #datas= decrtptlx(str12)
    datas = eval(datas)
    dataxx=pd.DataFrame()
    names =['relation_word_list','search_relation_word_list']
    for name in names:
        for word_info in datas['%s'%name]:
            dataxx = dataxx.append([{'keyword':keyword,'app_name':app_name,'start_date':date,'end_date':enddate,
                                     'listname':name,'relation_word':word_info['relation_word'],
                                     'relation_score':word_info['relation_score'],
                                     'score_rank':word_info['score_rank'],
                                     'search_hot':word_info['search_hot'],
                                     'search_ratio':word_info['search_ratio'],
                                     'correlation_change': 1 if 'true' in str(word_info['correlation_change']) else 0,
                                     'score_rate':word_info['score_rate'],
                                     'score_rate_rank':word_info['score_rate_rank']}],ignore_index=True)

    return
if __name__ == '__main__':
    get_relation_words_run()